﻿@model IEnumerable<Mvc5Ef6WebApiDataFirstNthW.Models.Category>
@using Mvc5Ef6WebApiDataFirstNthW.Helpers

@{
    ViewBag.Title = "Categories";
}
@section PrintToPdf
{
    @Html.ActionLink("PDF", ViewContext.RouteData.GetRequiredString("action") + "ToPdf", ViewContext.RouteData.GetRequiredString("controller"),null, new { @class = "pdfMenu"})
}

<header></header>

<h2>@ViewBag.Title</h2>

<h3>Responsive table plus No More Table</h3>
<section id="no-more-tables">
    <table class="table-bordered table-striped table-condensed cf">

        <thead class="cf">
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.CategoryName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Picture)
                </th>
                @*<th class="tdNotPrinted">Your choice</th>*@
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td data-title=@Html.DisplayNameFor(model => model.CategoryName)>
                        @Html.DisplayFor(modelItem => item.CategoryName)
                    </td>
                    <td data-title=@Html.DisplayNameFor(model => model.Description)>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    <td data-title=@Html.DisplayNameFor(model => model.Picture)>
                        @*Third method with HtmlHelper Image and ByteToStringImage*@
                        @Html.Image("img-responsive", Utils.ByteToStringImage(item.Picture), item.CategoryName, item.CategoryName, "0")
                    </td>

                    @*<td id="tdNotPrinted">
                            @Html.ActionLink("Edit", "Edit", new { id = item.CategoryID }) |
                            @Html.ActionLink("Details", "Details", new { id = item.CategoryID }) |
                            @Html.ActionLink("Delete", "Delete", new { id = item.CategoryID })
                        </td>*@
                </tr>
            }
        </tbody>

    </table>


</section>

<h3 id="h3PageBreak">Responsive table</h3>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.CategoryName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Picture)
                </th>
                @*<th class="tdNotPrinted">Your choice</th>*@
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td data-title=@Html.DisplayNameFor(model => model.CategoryName)>
                        @Html.DisplayFor(modelItem => item.CategoryName)
                    </td>
                    <td data-title=@Html.DisplayNameFor(model => model.Description)>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    @*First method code inline*@
                    @*@{byte[] photo = item.Picture;
                            string imageSrc = null;
                            if (photo != null)
                            {
                                MemoryStream ms = new MemoryStream();
                                ms.Write(photo, 78, photo.Length - 78); // strip out 78 byte OLE header (don't need to do this for normal images)
                                string imageBase64 = Convert.ToBase64String(ms.ToArray());
                                imageSrc = string.Format("data:image/png;base64,{0}", imageBase64);
                            }
                        }*@
                    <td data-title=@Html.DisplayNameFor(model => model.Picture)>
                        @*First method*@
                        @*<img class="img-responsive" src="@imageSrc" title="@item.CategoryName" alt="@item.CategoryName" border="0" />*@
                        @*Second method with Utils ByteToStringImage*@
                        @*<img class="img-responsive" src="@Utils.ByteToStringImage(item.Picture)" title="@item.CategoryName " alt="@item.CategoryName " border="0" />*@
                        @*Third method with HtmlHelper Image and ByteToStringImage*@
                        @*@Html.Image("img-responsive", Utils.ByteToStringImage(item.Picture), item.CategoryName, item.CategoryName, "0")*@
                        @*Fourth method with razor helper TagImage*@
                        @MyRazorHelpers.TagImage("img-responsive", item.Picture, @item.CategoryName, @item.CategoryName, "0")
                    </td>

                    @*<td class="tdNotPrinted">
                            @Html.ActionLink("Edit", "Edit", new { id = item.CategoryID }) |
                            @Html.ActionLink("Details", "Details", new { id = item.CategoryID }) |
                            @Html.ActionLink("Delete", "Delete", new { id = item.CategoryID })
                        </td>*@
                </tr>
            }
        </tbody>

    </table>
</div>
